/**
 * author: Hanflyee  flyee1980@163.com
 * vision: v1.0
 * data: 2009-7-9
 */
package com.flyee.viewer{
	
	import com.flyee.controller.SceneController;
	import com.flyee.service.CharactorService;
	import com.flyee.utils.DisplayObjectUtil;
	import com.flyee.utils.GenerateIDTool;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * 场景UI类
	 * 包含4个层次，并且保存相关控制器的引用 
	 */
	public class SceneViewer extends Sprite implements Destroy{
		
		/**UI元素的ID，必须生成*/
		public var vid : String = GenerateIDTool.generateID();
		
		//背景层
		public var backgroundLayer : Sprite = new Sprite();
		//地形层
		public var landLayer : Sprite = new Sprite();
		//组件层
		public var componentLayer : Sprite = new Sprite();
		//漂浮层
		public var driftLayer : Sprite = new Sprite();
		
		public function SceneViewer(){
			super();
			this.addChild(backgroundLayer);
			this.addChild(landLayer);
			this.addChild(componentLayer);
			this.addChild(driftLayer);
						
		}

		/**释放*/
		public function dispose() : void {
			DisplayObjectUtil.removeAll(backgroundLayer);
			DisplayObjectUtil.removeAll(landLayer);
			DisplayObjectUtil.removeAll(componentLayer);
			DisplayObjectUtil.removeAll(driftLayer);
			DisplayObjectUtil.removeAll(this);
			backgroundLayer = null;
			landLayer = null;
			componentLayer = null;
			driftLayer = null;
//			this.removeEventListener(MouseEvent.MOUSE_DOWN, this.startDrag);
//			this.removeEventListener(MouseEvent.MOUSE_UP, this.stopDrag);
		} 
		
	}
}